//
//  QYLoginViewController.m
//  CarPooling
//
//  Created by Dxc_iOS on 2018/5/14.
//  Copyright © 2018年 代星创. All rights reserved.
//

#import "QYLoginViewController.h"
#import "QYRegistViewController.h"
#import "QYForgetPasswordViewController.h"
#import "QYLoginTFView.h"


@interface QYLoginViewController ()
@property (nonatomic,strong) UIImageView *logoImgeView;
@property (nonatomic,strong) UIButton  *loginBtn;
@property (nonatomic,strong) UIButton  *registBtn;
@property (nonatomic,strong) UIButton  *forgotBtn;
@property (nonatomic,strong) QYLoginTFView *userTFView;
@property (nonatomic,strong) QYLoginTFView *passwordTFView;

@end

@implementation QYLoginViewController


- (void)viewDidLoad {
    [super viewDidLoad];
//    self.view.backgroundColor = BgColor;
    self.title = @"Logon";
    [self seupHomeUI];
   
}
-(void)seupHomeUI{
    _logoImgeView = [[UIImageView alloc] initWithFrame:CGRectMake(HDScreenWidth/2-50, 100, 100, 100)];
    _logoImgeView.backgroundColor = [UIColor redColor];
    [self.view addSubview:_logoImgeView];

    _userTFView = [[QYLoginTFView alloc] initWithFrame:CGRectMake(0, CGRectGetMaxY(_logoImgeView.frame)+55, HDScreenWidth, 40)];
    [self.view addSubview:_userTFView];
    _userTFView.secureTextBtnIsHidden = YES;
    _userTFView.icon.image = IMAGE(@"login_name");
    _userTFView.textTF.placeholder = @"Please enter phone number or email";
    _userTFView.textTF.clearsOnBeginEditing = YES;
    _userTFView.textTF.clearButtonMode = UITextFieldViewModeAlways;
    _userTFView.textTF.font =HDFont(14);
//
    _passwordTFView = [[QYLoginTFView alloc] initWithFrame:CGRectMake(0, CGRectGetMaxY(_userTFView.frame)+50, HDScreenWidth, 40)];
    [self.view addSubview:_passwordTFView];
    _passwordTFView.secureTextBtnIsHidden = NO;
    _passwordTFView.icon.image = IMAGE(@"login_password");
    _passwordTFView.textTF.placeholder = @"Please enter your password";
    _passwordTFView.textTF.clearsOnBeginEditing = YES;
    _passwordTFView.textTF.clearButtonMode = UITextFieldViewModeAlways;
    _passwordTFView.textTF.font =HDFont(14);
    

  
    //
    _registBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    [self.view addSubview:_registBtn];
    _registBtn.sd_layout.leftSpaceToView(self.view, 30).topSpaceToView(_passwordTFView, 10).heightIs(40).widthIs(120);
    [_registBtn setTitle:@"regist account" forState:UIControlStateNormal];
    [_registBtn setTitleColor:[UIColor grayColor] forState:UIControlStateNormal];
    _registBtn.titleLabel .font = HDFont(14);
    [_registBtn addTarget:self action:@selector(registBtnClick) forControlEvents:UIControlEventTouchUpInside];
    
    //
    _forgotBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    [self.view addSubview:_forgotBtn];
    _forgotBtn.sd_layout.rightSpaceToView(self.view, 30).topSpaceToView(_passwordTFView, 10).heightIs(40).widthIs(120);
    [_forgotBtn setTitle:@"forget password" forState:UIControlStateNormal];
    [_forgotBtn setTitleColor:[UIColor grayColor] forState:UIControlStateNormal];
    _forgotBtn.titleLabel .font = HDFont(14);
    [_forgotBtn addTarget:self action:@selector(forgotBtnClick) forControlEvents:UIControlEventTouchUpInside];
    
    //
    _loginBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    [self.view addSubview:_loginBtn];
    _loginBtn.sd_layout.leftSpaceToView(self.view, 30).rightSpaceToView(self.view, 30).topSpaceToView(_passwordTFView, 120).heightIs(40);
    _loginBtn.backgroundColor = LoginBtnColor ;
    [_loginBtn setTitle:@"Log in" forState:UIControlStateNormal];
    [_loginBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    _loginBtn.layer.cornerRadius = 6;
    [_loginBtn addTarget:self action:@selector(loginBtnClick) forControlEvents:UIControlEventTouchUpInside];
    
    
    
}


#pragma mark - Btn ACtion

-(void)forgotBtnClick{
    [self.navigationController pushViewController:[QYForgetPasswordViewController new] animated:YES];
}

-(void)registBtnClick{
    [self.navigationController pushViewController:[QYRegistViewController new] animated:YES];
}

-(void)loginBtnClick{
    DDLogDebug(@"登录");
     [MBProgressHUD showTipMessageInWindow:@"错误"];
}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
